//Tue Oct  4 14:45:42 PDT 2011
public class SRMSystemTestPhase {

	public String[] record;
	public int[][][] dp;
	public static final int mod = 1000000007;

	public int countWays(String[] description) {
		record = description;
		dp = new int[description.length + 1][4][4];

		for (int i = 0; i <= description.length; i++)
			for (int j = 0; j < 4; j++)
				for (int k = 0; k < 4; k++)
					dp[i][j][k] = -1;

		return solve(0, 3, 0);
	}

	public int solve(int pos, int pass, int cha) {
		if (pos == record.length)
			return 1;
		if (dp[pos][pass][cha] > -1)
			return dp[pos][pass][cha];
		int ret = 0;
		int aa = record[pos].charAt(0) == 'Y' ? 3 : 1;
		int bb = record[pos].charAt(1) == 'Y' ? 3 : 1;
		int cc = record[pos].charAt(2) == 'Y' ? 3 : 1;

		// 0:pass;
		// 1:chad;
		// 2:failed;

		// for (int mask = 0; mask < 8; mask++) {
		// int passed = 0;
		// int chad = 0;
		// for (int i = 0; i < 3; i++) {
		// if (record[pos].charAt(i) == 'Y')
		// if ((1 & (mask >> i)) == 1) {
		// passed++;
		// } else
		// chad++;
		// }
		// if (passed < pass || (passed == pass && chad >= cha))
		// ret = (ret + solve(pos + 1, passed, chad)) % mod;
		// }
		for (int a = 0; a < aa; a++)
			for (int b = 0; b < bb; b++)
				for (int c = 0; c < cc; c++) {
					int passed = 0;
					int chad = 0;
					if (record[pos].charAt(0) == 'Y' && a == 0)
						passed++;
					if (record[pos].charAt(0) == 'Y' && a == 1)
						chad++;
					if (record[pos].charAt(1) == 'Y' && b == 0)
						passed++;
					if (record[pos].charAt(1) == 'Y' && b == 1)
						chad++;
					if (record[pos].charAt(2) == 'Y' && c == 0)
						passed++;
					if (record[pos].charAt(2) == 'Y' && c == 1)
						chad++;
					if (passed < pass || (passed == pass && chad >= cha))
						ret = (ret + solve(pos + 1, passed, chad)) % mod;
				}
		return dp[pos][pass][cha] = ret;
	}
	// <%:testing-code%>
}
// Powered by [KawigiEdit] 2.0!
